package com.yzb.config;

import org.apache.catalina.startup.Tomcat;
import org.springframework.stereotype.Component;

@Component
public class MyTomcat implements WebServerFactory{
    String path = "D:\\Study\\ProgrammingProject\\IDEAProject\\JavaWebLagouLearn\\J1M4_210309_tomcat_homework";
    public void createServer() throws Exception {
        Tomcat tomcat=new Tomcat();
        tomcat.setPort(8080);
        tomcat.addWebapp("/",path);
        tomcat.start();
        //因为  tomcat.start();是非阻塞型的，所以要阻塞一下，不能让服务停止。
        tomcat.getServer().await();
    }
}
